/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.kth.lwr.jeat.samples.onsitetreatment.producers;

import se.kth.lwr.jeat.utils.AmountVolume;
import javax.measure.quantity.VolumetricDensity;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.jscience.physics.amount.Amount;
import se.kth.lwr.jeat.core.*;
import se.kth.lwr.jeat.samples.onsitetreatment.Units;
import se.kth.lwr.jeat.utils.ProductionSupport;
import se.kth.lwr.jeat.samples.onsitetreatment.SimpleProduction;

/**
 *
 * @author davidev
 */
public class MacadamExtraction extends SimpleProduction {

    private MacadamExtraction(ProductionSupport support) {
        super(support);
    }
    
    public static MacadamExtraction getInstance(){
        ProductionSupport support= new ProductionSupport("macadam", macadamExtraction, SI.CUBIC_METRE);
        return new MacadamExtraction(support);
        
    }

    
    public Activity getProduction(String name, String desc, AmountVolume volume, AmountDataSource duration, AmountDataSource pe) {
        AmountFunction function = volume.getVolume().divide(duration).divide(pe);
        return super.getProduction(name, desc, function);
    }
    
    

    
    /**
     * Density of macadam
     * <p/>
     * Value: 1900
     * <p/>
     * Unit: kg/m3
     */
    public static final AmountDataSource<VolumetricDensity> densityMacadam = new AmountDataSource<>(
            "densityMacadam",
            "Density of macadam",
            Amount.valueOf(1900, (Unit<VolumetricDensity>) SI.KILOGRAM.divide(SI.CUBIC_METRE)));
    /**
     * Consumtion during extraction of 1 m3 macadam
     *
     */
    public static final InventoryDataSource macadamExtraction = new InventoryDataSource("macadamExtraction",
            "Consumtion during extraction of macadam",
            new Inventoriable() {

                @Override
                public Inventory getInventory() {
                    Inventory retval = Inventory.emptyInventory();
                    retval.addEnergyUse(EnergyCategory.ELECTRICAL, Amount.valueOf(11.15, Units.MEGA_JOULE_PER_CUBIC_METER));
                    retval.addEnergyUse(EnergyCategory.FOSSIL, Amount.valueOf(8.98, Units.MEGA_JOULE_PER_CUBIC_METER));
                    retval.addResourceUse(ResourceCategory.MACADAM, Amount.valueOf(1.0, Unit.ONE));
                    return retval;


                }
            });
    

}
